package com.itheima.service.db.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.itheima.domain.db.QuestionBelongTo;
import com.itheima.domain.vo.PageBeanVo;
import com.itheima.mapper.QuestionBelongToMapper;
import com.itheima.service.db.QuestionBelongToService;
import org.apache.dubbo.config.annotation.Service;

import org.springframework.beans.factory.annotation.Autowired;

@Service
public class QuestionBelongToServiceImpl implements QuestionBelongToService {
    @Autowired
    private QuestionBelongToMapper questionBelongToMapper;

    /*
     *  添加问题归属
     *
     * @param questionBelongTo  问题归属类
     * @author
     * @date
     * @return java.lang.Integer
     */

    @Override
    public Integer saveQuestionBelongTo(QuestionBelongTo questionBelongTo) {
      return   questionBelongToMapper.insert(questionBelongTo);
    }


    /*
     *
     *
     * @param pageNum   当前页
     * @param pageSize  页数大小
     * @author
     * @date
     * @return com.itheima.domain.vo.PageBeanVo
     */

    @Override
    public PageBeanVo findQuestionBelongToByPage(Integer pageNum, Integer pageSize) {
        IPage page=new Page(pageNum,pageSize);
        page=questionBelongToMapper.selectPage(page,null);
        return new PageBeanVo(pageNum,pageSize,page.getTotal(),page.getRecords());
    }
}
